package com.erp.controller;

import com.erp.domain.Course;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping
@RestController
public class UserController {

//    @Autowired
//    private DefaultMQProducer defaultMQProducer;

    @GetMapping("/send")
    public void send() {
        try {
            Message msg = new Message("TopicTest", "TagA", "Hello RocketMQ".getBytes(RemotingHelper.DEFAULT_CHARSET));
//            defaultMQProducer.send(msg);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @PostMapping("/course")
    public void course(@RequestBody Course course, HttpServletRequest request) {
        log.info("course type {}", course.getType());
        log.info("request header {}", request.getHeader("appId"));
    }
}
